<?php
class WebsiteLinkAction extends CommonAction{
      /*+-----------------------------------
        |     站内链接管理
        +-----------------------------------
       */
       public function index(){
               //获取站内链接列表
               $this->changeDB();
               $link = D("website_link");
               if($_GET['search']){
                   $where = "link_name like '%{$_GET['keyWord']}%'";
               }else{
                   $where = "1=1";
               }
               $limit       = $this -> pageOperate("website_link",10,$where);
               $websiteLink = $link -> where($where) ->limit("{$limit['firstRow']},{$limit['listRows']}")->order("id desc") -> select();
               $this->assign("websiteLink",$websiteLink);     
               $this->display();
       }

       public function addWebsiteLink(){
               if($_POST['save']){
                     
                     if(!empty($_FILES['image']['name'])){
                         $link['maxSize']           = "-1";   //不限定上传大小
                         $link['allowExts']         = "jpg,jpeg,png,gif";     //设定允许上传的类型
                         $link['thumbPrefix']       = "";                     //设置缩略图的前缀
                         //设置宽高
                         $linkSize                  = explode("x",$_POST['link_imageSize']);
                         $link['thumbMaxWidth']     = $linkSize[0];
                         $link['thumbMaxHeight']    = $linkSize[1];
                         $fileUploadResult          = $this->_upload($link);
                         $_POST['link_image']       = date('Y')."/".date("m")."/".date("d")."/s_".$fileUploadResult[0]['savename'];
                     }
                     $_POST['create_time'] = time(); 
                     $this->changeDB();
                     $websiteLink = D("website_link");
                     $add         = $websiteLink ->add($_POST);
                     if($add){
                                  $this->success("添加站内链接成功！");
                     }else{
                                  $this->error("添加站内链接失败！");
                     }
               }
               $this->display();
       }

       public function editWebsiteLink(){
              if($_POST['edit'] && $_POST['del']){
                     
              }
              $this->display();
       }

       public function delWebsiteLink(){
        
               $this->display();
       }
} 
?>
